import time

from selenium import webdriver

a = webdriver.Chrome()
a.get("https://flight.qunar.com/")
# 定位到div
# # div01 = a.find_element_by_xpath("//div[@class='m-search-bd']/div[@class='m-search-item g-clear']")
# form01 = a.find_element_by_xpath("//form[@id='dfsForm']")
# # 进入div
# # a.switch_to.(div01)
# a.switch_to(form01)
# 获取用户输入信息
# cfd_input = input("请输入出发地")
# ddd_input = input("请输入到达地")
# time01_input = input("请输入出行时间")
# # 将用户输入的信息模拟输入到网页
# cfd = a.find_element_by_xpath("//input[@value name='fromCity']").send_keys(cfd_input)
# ddd = a.find_element_by_xpath("//input[@value name='toCity']").send_keys(ddd_input)
# # time02 = a.find_element_by_xpath("//input[@data-reactid='.0.0.1.0.0.1.0.3.0.0']").clear()
# time01 = a.find_element_by_xpath("//input[@value id ='fromDate']").send_keys(time01_input)
# # 模拟用户点击搜索按钮
# # button01 = a.find_element_by_xpath("//button[@data-reactid='.0.0.1.0.0.1.0.9']").click()
# 出发地
a.find_element_by_xpath("//input[@data-qcbox-suggest='flight-fromcity']").clear()
a.find_element_by_xpath("//input[@data-qcbox-suggest='flight-fromcity']").send_keys('淮安')
time.sleep(2)
# 到达地
a.find_element_by_xpath("//input[@data-qcbox-suggest='flight-tocity']").clear()
a.find_element_by_xpath("//input[@data-qcbox-suggest='flight-tocity']").send_keys('长沙')
time.sleep(2)
# 时间
# a.find_element_by_xpath("//input[@data-prefix='出发']").clear()
a.find_element_by_xpath("//input[@data-prefix='出发']").send_keys('2020-12-20')
time.sleep(2)
# 模拟用户点击
# a.find_element_by_xpath("//button[@data-track='key=101020008&val=国内搜索']").click()

